﻿using System;

namespace ControleRepresentante.Common
{
    public static class StringHelper
    {
        public static bool IsNullOrWhiteSpace(string value)
        {
            return String.IsNullOrEmpty(value) || String.IsNullOrEmpty(value.Trim());
        }

        public static string FormatForDisplay<T>(this T value)
        {
            if (value == null)
            {
                return String.Empty;
            }

            DateTime? dateTime = value as DateTime?;
            bool? boolValue = value as bool?;
            if (dateTime.HasValue)
            {
                return dateTime.Value.ToShortDateString();
            }
            if (boolValue.HasValue)
            {
                return boolValue.Value ? "Sim" : "Não";
            }
            return value.ToString();
        }
    }
}
